package com.szh.mysobproject.hiltdemo;

import android.widget.ImageView;

import androidx.core.content.ContextCompat;

import com.szh.mysobproject.widget.GoTopScrollView;
import com.szh.mysobproject.R;
import com.szh.mysobproject.action.MyStatusAction;
import com.szh.mysobproject.app.AppActivity;
import com.szh.mysobproject.ui.dialog.MenuDialog;
import com.szh.mysobproject.widget.MyStatusLayout;

import javax.inject.Inject;

import dagger.hilt.android.AndroidEntryPoint;
import timber.log.Timber;

@AndroidEntryPoint
public class HiltActivity extends AppActivity implements MyStatusAction {

    private MyStatusLayout myStatusLayout;

    private GoTopScrollView goTopSl;
    private ImageView ivGoTop;




    @Inject
    HttpObject httpObject;

    @Inject
    HttpObject httpObject2;

    @Inject
    public TestInterface testInterface;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_hilt;
    }

    @Override
    protected void initView() {
//        myStatusLayout = findViewById(R.id.my_StatuesLayout);
        Timber.d("httpobj%s", httpObject.hashCode());
        Timber.d("httpobj2%s", httpObject2.hashCode());
        testInterface.method();

        goTopSl = (GoTopScrollView) findViewById(R.id.goTopSl);
        ivGoTop = (ImageView) findViewById(R.id.iv_goTop);
    }

    @Override
    protected void initData() {
        new MenuDialog.Builder(this)
                .setList("加载中", "请求错误", "空数据提示", "自定义提示")
                .setListener((dialog, position, object) -> {
                    switch (position) {
                        case 0:
                            showLoading();
                            postDelayed(this::showComplete, 3000);
                            break;
                        case 1:
                            showError(layout -> showLoading());
                            break;
                        case 2:
                            showEmpty();
                            break;
                        case 3:
                            showLayout(ContextCompat.getDrawable(this, R.drawable.safe_ic), "ahahah", layout -> showLoading());
                    }
                });

    }

    @Override
    public void initEvent() {
        goTopSl.setScrollListener(ivGoTop);
        goTopSl.setScreenHeight(0);
    }

    @Override
    public MyStatusLayout getMyStatusLayout() {
        return null;
    }
}
